<template>
  <div class="home-recommond">
    <h1>每日推荐</h1>
    <div class="wrapper" ref="wrapper">
      <!--滚动所需的容器-->
      <ul class="content" ref="content">
        <li
          v-for="(item, index) in listData"
          :key="index"
          @click="selectItem(item)"
        >
          <div class="bodys">
            <van-image :src="item.picUrl" class="cover" radius="10px" />
            <span>{{ item.name }}</span>
            <span>{{ item.song.artists.name }}</span>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
// import { betterScrollHorizontal } from "../../common/betterScroll.js"; //引入betterscroll
export default {
  data() {
    return {
      listData: [],
    };
  },
  created() {
    this.getSongRecommend();
  },
  methods: {
    getSongRecommend() {
      this.$request("get", "/personalized/newsong").then((res) => {
        // console.log(res);
        if (res.code == 200) {
          this.listData = res.result;
          console.log(this.listData);
        }
      });
    },
  },
};
</script>
<style scoped>
.bodys {
  display: flex;
  align-items: center;
}
ul.content li {
  /* li默认使用块级元素 */
  display: inline-block; /**行内元素*/
  width: 10rem;
  vertical-align: top; /**垂直方向的algin顶满上一个div */
}
.cover {
  width: 50%;
  height: 50%;
}
.content {
  background: chartreuse;
}
</style>